package medium;

/**
 * 2924. 找到冠军 II
 * 创建时间：2024-04-13 11:48
 * 地址：https://leetcode.cn/problems/find-champion-ii/description/
 */
public class 找到冠军II_2924 {
    static class Solution {
        public int findChampion(int n, int[][] edges) {
            boolean[] isWeak = new boolean[n];
            // 标记弱队
            for (int[] edge : edges) {
                isWeak[edge[1]] = true;
            }

            int ans = -1;
            for (int i = 0; i < isWeak.length; i++) {
                if (!isWeak[i]) {
                    if (ans != -1) {
                        return -1;
                    }
                    ans = i;
                }
            }
            return ans;
        }
    }
}
